<template>
	<sw-form-frame v-model="visible" :title="formName" width="480" :type="formType" :loading="btnLoading" footer @submit="handleSubmitForm()">
		<el-form ref="form" size="medium" :model="formData" :rules="formRules" label-width="80px" v-loading="loading">
			<el-form-item label="名单名称" prop="name">
				<el-input v-model="formData.name"></el-input>
			</el-form-item>
			<el-form-item label="名单类型" prop="type">
				<el-radio-group v-model="formData.type" aria-hidden>
					<el-radio label="1">黑名单</el-radio>
					<el-radio label="2">白名单</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item label="IP地址" prop="ipAddr">
				<sw-ip-input placeholder="请输入IP地址" v-model="formData.ipAddr" size="medium" style="width: 200px"></sw-ip-input>
			</el-form-item>
		</el-form>
	</sw-form-frame>
</template>

<script>
import formMixins from '@/mixins/formMixins';
import { blackDetail, addedBlack, updateBlack } from '@/api/system/tbSysBlack';
export default {
	mixins: [formMixins],
	props: {
		type: { type: String, default: '' }
	},
	data() {
		return {
			formName: '名单',
			formRules: {
				name: [{ required: true, message: '请输入名单名称', trigger: 'blur' }],
				ipAddr: [{ required: true, message: '请输入IP地址', trigger: 'blur' }]
			}
		};
	},
	computed: {
		detailData() {
			return eval(blackDetail);
		},
		callFunction() {
			return eval(this.addOrEdit ? addedBlack : updateBlack);
		}
	},
	methods: {
		formatFormParams() {
			this.$set(this.formData, 'type', this.type);
		}
	}
};
</script>

<style lang="scss" scoped>
.role_form_wrapper::v-deep {
	width: 100%;
	padding: 10px 6px 0 0;
	box-sizing: border-box;
}
</style>
